package com.example.controller;

import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @auth shanyue
 * @date 2025年06月06日14:51
 */
@Controller
public class IndexController {

    @GetMapping({"/", "/index"})
    public String index(Model model, Authentication authentication) {
        if (authentication != null) {
            model.addAttribute("username", authentication.getName());
        } else {
            model.addAttribute("username", "游客");
        }
        return "index";
    }

}
